﻿using Newtonsoft.Json.Linq;
using System;
using System.Linq;

namespace DVM.DV.Model
{
    public static class Mapper
    {
        public static InitInfoV2 Map(InitInfo entity)
        {
            return new InitInfoV2
            {
                SourceName = entity.SourceName,
                SourceType = entity.SourceType,
                SourcePropertyInfos = entity.SourcePropertyInfos,
                OutPutName = entity.OutPutName,
                OutPutType = entity.OutPutType,
                //OutPutPropertyInfos = entity.OutPutPropertyInfos.ToList(),
                FieldPropertyInfoV2 = new FieldPropertyInfoV2
                {
                    PropertySetName = entity.FieldPropertyInfoV2.PropertySetName,
                    FieldType = entity.FieldPropertyInfoV2.FieldType,
                    FieldValue = entity.FieldPropertyInfoV2.FieldValue?.ToList()
                },
                FieldPropertyInfoV2s = entity.FieldPropertyInfoV2s.ConvertAll(entityFieldPropertyInfoV2 => new FieldPropertyInfoV2
                {
                    PropertySetName = entityFieldPropertyInfoV2.PropertySetName,
                    FieldType = entityFieldPropertyInfoV2.FieldType,
                    FieldValue = entityFieldPropertyInfoV2.FieldValue?.ToList()
                })
            };
        }
        //entity.OutPutPropertyInfos.ToDictionary(x=>x.Key,s=> new FieldPropertyInfoV2 
        //       {
        //           PropertySetName = s.Value.PropertySetName,
        //           FieldType = s.Value.FieldType,
        //           FieldValue = s.Value.FieldValue?.ToList()
        //       })
    }
}
